import { myAddAge, myRecharge } from './mutation-types'
const mutations = { // 修改数据唯一的正确途径，类似组件中的methods
    [myAddAge](state) {
        // 每次修改vuex时  也立即修改localStorage 保证数据同步
        state.age++
        // state.userinfo = {}  退出登录时清空用户信息
        localStorage.setItem('store', JSON.stringify(state))
    },
    [myRecharge](state, payload) {
        state.money += Number(payload)
        localStorage.setItem('store', JSON.stringify(state))
    },
    myRechargeObj(state, aa) {
        state.money += Number(aa.money)
        localStorage.setItem('store', JSON.stringify(state))
    },
    savePlay(state, info) {
        state.play = info;
        localStorage.setItem('store', JSON.stringify(state))
    }
};

export default mutations